<%@ taglib uri="http://www.ptc.com/windchill/taglib/fmt" prefix="fmt"%>
<%@taglib tagdir="/WEB-INF/tags" prefix="wctags"%>
<%@ include file="/netmarkets/jsp/util/begin.jspf"%>
<%@ page import="ext.acae2.cad.resource.CadResource"%>
<fmt:setLocale value="${localeBean.locale}" />
<fmt:setBundle basename="ext.acae2.cad.resource.CadResource" />
<fmt:message var="cadsignTitle" key="<%= CadResource.CADEPM_TITLE%>" />
<fmt:message var="cadnumber" key="<%= CadResource.NEED_SIGN_CADNUMBER%>" />
<fmt:message var="cadsignResult" key="<%= CadResource.CAD_SIGN_RESULT%>" />
<fmt:message var="cadsignbutton" key="<%= CadResource.CAD_SIGN_BUTTON%>" />

<%
String serverName = request.getServerName();
String contextPath = request.getContextPath();
String scheme = request.getScheme();
String fullPath = scheme+"://"+serverName+contextPath;
%>

<script type="text/javascript">
cadSignCallback = function(objects){
	var cadPicked = objects.pickedObject;
	var cadEpmName='';
	var signOids = '';
	for(var i=0;i<cadPicked.length;i++){
		var cadname = cadPicked[i].name;
		var cadOid = cadPicked[i].oid;
		if(i==cadPicked.length-1){
			cadEpmName = cadEpmName+cadname;
			signOids = signOids+cadOid
		}else{
			cadEpmName = cadEpmName+cadname+",";
			signOids = signOids+cadOid+"#";
		}
	}
	cadEpmName = cadEpmName.trim();
	signOids = signOids.trim();
	Ext.get("epmdocSearch$label$").dom.value=cadEpmName;
	Ext.get("signOids").dom.value= signOids;
}

signCad = function(){
	var cadSignName = Ext.get("epmdocSearch$label$").dom.value;
	
	if(!cadSignName){
		return ;
	}else{
		document.getElementById("result").innerHTML ="loading.....";
		document.getElementById("signcad").disabled="disabled";
		var oids = Ext.get("signOids").dom.value;
		 Ext.Ajax.request({
		        url: '<%=fullPath%>/netmarkets/jsp/ext/acae2/epmDoc/cad/sign_ajax.jsp',
		        success:function(response){
		        	document.getElementById("signcad").disabled="";
		        	document.getElementById("result").innerHTML= response.responseText.trim();
		        },
		        failure:function(response){
		        },
		        params:{
		            oids:oids
		        }
		    });
	}
}
</script>

<table>
	<tr>
		<wctags:genericPicker id="epmdocSearch" componentId="EPMDocumentModel2D"
			objectType="wt.epm.EPMDocument" inline="false" multiSelect="true"
			readOnlyPickerTextBox="true" pickedAttributes="name" label="* ${cadnumber}"
			pickerCallback="cadSignCallback"
			customAccessController="com.ptc.windchill.enterprise.search.server.LatestVersionAccessController" />
	</tr>
	<input type="hidden" id="signOids" value="" name="signOids"/>
	<!-- baseWhereClause="(state.state='RELEASED')"  -->
</table>
<table width='50%' style='margin-left: 10%'>
	<tr>
		<td align="center"><input type="button" onclick="signCad()"
			value="${cadsignbutton}" id="signcad"/></td>
	</tr>
</table>
<br>
<br>
<br>
<table>
	<tr>
		<td><font style="font-weight: bold;">${ cadsignResult}</font></td>
	</tr>
</table>
<div id="result" style="margin-left: 5%; font-weight: bold;"></div>
<%@ include file="/netmarkets/jsp/util/end.jspf"%>





